package net.starwifi.duobao.web;

import net.starwifi.duobao.entity.Member;
import net.starwifi.duobao.mvc.*;
import net.starwifi.duobao.service.MemberService;
import net.starwifi.duobao.service.TradeRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;

/**
 * Created by Administrator on 2015/9/28.
 */
@Controller("apiTradeRecordController")
@RequestMapping("/tradeRecord")
public class TradeRecordController extends BaseController {




    @Autowired
    TradeRecordService tradeRecordService;

    @Autowired
    MemberService memberService;

    /**
     * 列表
     */
    @ResponseBody
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public Object list(int pageNum) {
        Member member=memberService.getCurrent();
        PageView pageView=new PageView(pageNum,10);
        pageView.addFilter(Filter.eq("memberId",member.getId()));
        pageView.addOrder(Order.desc("id"));
        final Page page=tradeRecordService.getScrollData(pageView);
        return Message.createMessage(Message.success("success"), new HashMap<String, Object>() {{
            put("list",page.getContent());
        }});
    }


}
